package com.cskaoyan.controller;

import com.cskaoyan.bean.bo.AdminBrandBO;
import com.cskaoyan.bean.bo.AdminBrandDeleteBO;
import com.cskaoyan.bean.bo.AdminBrandUpdateBO;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.vo.admin_brand.AdminBrandCreateVO;
import com.cskaoyan.bean.vo.admin_brand.AdminBrandListVO;
import com.cskaoyan.service.AdminBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: Ryan
 * @CreateTime: 2022-09-07  14:58
 */
@RestController
@RequestMapping("/admin/brand/*")
public class AdminBrandController {

    @Autowired
    AdminBrandService adminBrandService;

    @RequestMapping("list")
    public BaseRespVo adminBrandList(Integer page,Integer limit,String sort,String order,String name,Integer id) {
        BaseRespVo<Object> baseRespVo = new BaseRespVo<>();
        baseRespVo.setErrmsg("成功");
        baseRespVo.setErrno(0);
        CommonData<AdminBrandListVO> commonData = new CommonData<>();
        commonData =adminBrandService.getAdminBrandList(page,limit,sort,order,name,id);
        baseRespVo.setData(commonData);
        return baseRespVo;
    }
    @RequestMapping("create")
    public BaseRespVo adminBrandCreate(@RequestBody AdminBrandBO adminBrandBO) {
        BaseRespVo<Object> baseRespVo = new BaseRespVo<>();
        baseRespVo.setErrmsg("成功");
        baseRespVo.setErrno(0);
        AdminBrandCreateVO adminBrandCreateVO =adminBrandService.creatAdminBrand(adminBrandBO);
        baseRespVo.setData(adminBrandCreateVO);
        return baseRespVo;
    }

    @RequestMapping("update")
    public BaseRespVo adminBrandUpdate(@RequestBody AdminBrandUpdateBO adminBrandUpdateBO) {
        BaseRespVo<Object> baseRespVo = new BaseRespVo<>();
        baseRespVo.setErrmsg("成功");
        baseRespVo.setErrno(0);
        AdminBrandCreateVO adminBrandCreateVO =adminBrandService.updateAdminBrand(adminBrandUpdateBO);
        baseRespVo.setData(adminBrandCreateVO);
        return baseRespVo;
    }

    @RequestMapping("delete")
    public BaseRespVo adminBrandDelete(@RequestBody AdminBrandDeleteBO adminBrandDeleteBO) {
        BaseRespVo<Object> baseRespVo = new BaseRespVo<>();
        baseRespVo.setErrmsg("成功");
        baseRespVo.setErrno(0);
        adminBrandService.deleteAdminBrand(adminBrandDeleteBO);

        return baseRespVo;
    }
}
